package com.java.demo1;

import java.util.Arrays;

public class Test01 {

    public static void main(String[] args) {

        //1-100 逢7过
//        for (int i = 1; i <= 100; i++) {
//            if (i % 10 == 7 || i / 10 % 10 == 7 || i % 7 == 0) {
//                System.out.println(i);
//            }
//        }

        //数组元素求和
//        int[] arr = {71, 27, 33, 22, 100, 87, 77, 57};
//        int sum = 0;
//        for (int i = 0; i < arr.length; i++) {
//            if (arr[i] % 2 == 0 && arr[i] / 10 % 10 != 7) {
//                System.out.println(arr[i]);
//                sum += arr[i];
//            }
//        }
//        System.out.println(sum);

        int[] arr1 = {1,2,34,5,6,7};
//        int[] arr2 = {1,2,5,6,7};
//        int[] arr3 = {1,2,4,5,6,7};
//
//        System.out.println(compare(arr1,arr2));
//        System.out.println(compare(arr1,arr3));

        reversed(arr1);

    }

    /*
    * 判断两个数组是否相同
    * */
    public static boolean compare(int[] arr1, int[] arr2){
        //判断数组长度
        if(arr1.length != arr2.length){
            return false;
        }
        //循环遍历，判断每个元素是否相同
        for (int i = 0; i < arr1.length; i++) {
            if(arr1[i] != arr2[i]){
                return false;
            }
        }
        return true;
    }

    /*
    * 反转数组
    * */
    public static void reversed(int[] arr ) {
        //双指针
        for(int start = 0, end = arr.length-1; start < end; start++, end--) {
            int temp = arr[start];
            arr[start] = arr[end];
            arr[end] = temp;
        }
        System.out.println(Arrays.toString(arr));
    }

}
